<?php

	class AboutController extends Zend_Controller_Action {
		
		public function init() {
			
			$this->view->headLink()
					->appendStylesheet($this->_request->getBaseUrl().'/styles/commun.css')
					->appendStylesheet($this->_request->getBaseUrl().'/styles/template.css')
					->appendStylesheet($this->_request->getBaseUrl().'/styles/about.css');
			
			$this->view->action = $this->_request->getActionName();
			$this->view->controller = $this->_request->getControllerName();
			
			// check what we want to see
			$cM = new Model_UsersDatas();
			$what_temp = $this->_request->getActionName();
			if(!is_null($what_temp) and !empty($what_temp)) {
				$filter = array('keyname' => $what_temp);
				$what = $cM->get($filter);
				
				if(count($what) == 1) {
					$this->view->datas = $what[0];
					// if hybridlegacy, go to "us" action
					if($what[0]['id_user'] == 1) {
						$this->_forward('us', $this->view->controller_name, 'frontend', array());
					
					// if association, go to "association" action
					} elseif($what[0]['keyname'] == 'association') {
						$this->_forward('association', $this->view->controller_name, 'frontend', array());
					
					// else, show member
					} else {
						$this->_forward('crew', $this->view->controller_name, 'frontend', array());
					}
					return;
				} else {
					$this->view->error = true;
					$this->view->error_message = 'Erreur lors de la récupération des informations';
					$this->_forward('index', $this->view->controller_name, 'frontend', array());
				}
			}
		}
		
		public function indexAction() {
			
			$this->view->headTitle('Hybrid Legacy - A propos');
			
		}
		
		public function usAction() {
			
			$this->view->headTitle('Hybrid Legacy - A propos du groupe');
			
			// get all crew members
			$cm = new Model_UsersDatas();
			
			$filter = array();
			$order = 'firstname';
			$members_temp = $cm->get($filter, $order);
			$members = array();
			
			// get rid of Hybrid Legacy and Association
			foreach($members_temp AS $m) {
				if($m['id_user'] != '1' and $m['id_user'] != '2') {
					$members[] = $m;
				}
			}
			
			$this->view->members = $members;
			
		}
		
		public function associationAction() {
			
			
		
		}
		
		public function crewAction() {
			
			$this->view->headTitle('Hybrid Legacy - A propos du danseur');
			
			// get all crew members
			$cm = new Model_UsersDatas();
			
			$filter = array();
			$order = 'firstname';
			$members_temp = $cm->get($filter, $order);
			$members = array();
			
			// get rid of Hybrid Legacy and Association
			foreach($members_temp AS $m) {
				if($m['id_user'] != '1' and $m['id_user'] != '2') {
					$members[] = $m;
				}
			}
			
			$this->view->members = $members;
			
		}
		
	}
	
?>
